#include <stdint.h>
#include <8052.h>

#include "misc.h"
#include "say_hello.h"


void sayhello()
{
    #define DULA P2_6 //段选位 用于数码的显示锁存
    #define WELA P2_7 //位选位 用于哪个数码的显示锁存
    //16位数码管
    // __code unsigned char table[] = {
    //     0x3f, 0x06, 0x5b, 0x4f,
    //     0x66, 0x6d, 0x7d, 0x07,
    //     0x7f, 0x6f, 0x77, 0x7c,
    //     0x39, 0x5e, 0x79, 0x71};

    //HELLO.
    __code unsigned char HELLO[] = {0x76, 0x79, 0x38, 0x38, 0x3f, 0x80};

    uint8_t i = 0;
    while (1)
    {
        //哪个数码管显示,0为要显示的数码管
        unsigned char showIndex = 0xFE; //11111110
        for (i = 0; i < 6; i++)
        {
            //此处要关闭数码管显示，否则在位选的时候有干扰影响
            P0 = 0;
            DULA = 1;
            DULA = 0;

            //P0=0xff; //重置为空,位选0进行选择
            P0 = showIndex; //设置哪个数码管显示
            WELA = 1;       //位选开启
            WELA = 0;       //位选锁定
            //delay(1000);

            //P0=0; //重置为空,数码管高电位显示数字
            P0 = HELLO[i];
            DULA = 1;
            DULA = 0;
            //delay(1000);

            showIndex = crol(showIndex); //左移位
        }
    }
}
